package com.lance.quartz.common.job;

import com.lance.quartz.domain.TaskInfo;
import com.lance.quartz.service.TaskServiceImpl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 该方法仅仅用来测试每分钟执行
 *
 * @author lance
 */
public class MinuteJob implements Job {
    Logger logger = LogManager.getLogger(getClass());

    @Autowired
    private TaskServiceImpl taskService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        List<TaskInfo> taskInfoList = taskService.list();
        logger.info("JobName: {},JobGroup: {}", context.getJobDetail().getKey().getName(), context.getJobDetail().getKey().getGroup());
    }
}